//
//  AudioPlayer.h
//  ZYTS-iPhone
//
//  Created by yuzhou on 12-12-12.
//  Copyright (c) 2012年 wzyk. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
#import <AudioToolbox/AudioToolbox.h>
#import "AudioStreamer.h"

typedef enum {
    AudioPlayerStateNone = 0,
    AudioPlayerStatePlaying,
    AudioPlayerStateStoped
} AudioPlayerState;

typedef enum {
    AudioPlayerModeAllLoop = 0,
    AudioPlayerModeSingleLoop,
    AudioPlayerModeRandom,
    AudioPlayerModeNum
} AudioPlayerMode;

@interface AudioProgress : NSObject
@property float lenght;
@property float position;
@end



@interface AudioPlayer :UIResponder <AVAudioPlayerDelegate,AVAudioSessionDelegate>
{
    AVAudioPlayer *avAudioPlayer;
    AudioStreamer *streamerAudioPlayer;
    NSTimer *progressTimer;
    BOOL pausedByInterruption;
    BOOL historyFoward;
    float historyFowardTime;
}
+ (AudioPlayer *)defaultPlayer;
- (void)playlist:(NSArray *)listArray fromIndex:(int)index;
- (void)play;
- (void)playIndex:(int)index;
- (void)stop;
- (void)pause;
- (void)playNext;
- (void)playPrevious;
- (void)playAtTime:(float)percent;
- (void)setHistoryFowardTime:(float)time;
- (NSDictionary *)currentItem;
- (AudioPlayerState)playerState;
- (void)audio_remoteControlReceivedWithEvent:(UIEvent *)event;
@property (nonatomic,retain) NSArray *playlist;
@property BOOL running;//播放是否在进行
@property int playingIndex;
@property AudioPlayerMode playerMode;
@end